<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小记者投稿</title>

    <link href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link href="../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}" rel="stylesheet">
    <!-- Morris -->
    <link href="https://cdn.bootcss.com/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/animate.css/2.1.1/animate.min.css" rel="stylesheet">
    <link href="../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}" rel="stylesheet">

    <style type="text/css">
        .hr-line-dashed {
            margin: 10px 0;
            height: 1px;
            border-top: 1px dashed #e7eaec;
            background-color: #fff;
            color: #fff;
        }

        .gohome {
            display: none !important;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight tooltip-demo">
    <!--search-->
    <form role="form" id="searchForm" class="search-panel" method="get" th:object="${condition}">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="form-inline">
                            <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="school">学校：</label>
                                <input type="text" class="form-control input-sm mb10" id="school" th:value="*{school}" name="school" placeholder="学校" style="width: 156px;"/>
                            </div>

                            <div class="form-group m-r-sm">
                                <label class=" control-label">班级：</label>
                                <input type="text" class="form-control input-sm mb10" id="className" th:value="*{className}" name="className" placeholder="班级" style="width: 156px;"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="reporterName">小记者名称：</label>
                                <input type="text" class="form-control input-sm mb10" id="reporterName" th:value="*{reporterName}" name="reporterName" placeholder="小记者名称" style="width: 156px;"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="reporterNum">小记者证号：</label>
                                <input type="text" class="form-control input-sm mb10" id="reporterNum" th:value="*{reporterNum}" name="reporterNum" placeholder="小记者证号" style="width: 156px;"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <button type="button" onclick="listHandler.search(1)" class="btn btn-primary btn-sm m-b-none">筛选</button>
                                <button type="button" onclick="listHandler.searchAll()" class="btn btn-primary btn-sm m-b-none">显示全部</button>
                                <button type="button" onclick="listHandler.exportExcel()" class="btn btn-primary btn-sm m-b-none">导出当页</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->

    <!--list-->
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="ibox-content p-xxs no-top-border">

                    <div class="panel-body">
                        <table class="table table-bordered table-hover table-center">
                            <thead>
                            <tr>
                                <th>小记者证号</th>
                                <th>小记者名称</th>
                                <th>学校</th>
                                <th>班级</th>
                                <th>标题</th>
                                <th>投稿时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            <tr th:each="item:${contributions}">
                                <td th:text="${item.reporterNum}"></td>
                                <td th:text="${item.reporterName}"></td>
                                <td th:text="${item.school}"></td>
                                <td th:text="${item.className}"></td>
                                <td th:text="${item.title}"></td>
                                <td th:text="${item.createTimeFormat}"></td>
                                <td>
                                    <a th:href="@{/bDetail(id=${item.id})}">详情</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <p style="float: left; margin: 20px 0;">
                            共<span th:text="${totalRecords}"></span>条记录，当前第<span th:text="${pageIndex}"></span>/<span th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                        </p>
                        <ul style="float: right;" class="pagination pagination-split">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<iframe id="exportDiv" src="" style="display: none"></iframe>
<!--基础框架js-->
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="../resource/hotui/js/hot/bootstrap.hot.extra-utils.js" th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js}"></script>
<script src="../resource/hotui/js/hot/bootstrap.hot.extra-init.js" th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js}"></script>
<script src="../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script type="text/javascript" th:inline="javascript">
    var pageIndex = /*[[${pageIndex}]]*/  1;
    var totalPages = /*[[${totalPages}]]*/  0;
    var pageUri = /*[[@{/bList}]]*/  "";
    var ajaxUri = /*[[@{/manager/}]]*/  "";
    var exportUri = /*[[@{/export}]]*/  "";
</script>
<script>
    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            listHandler.search(p);
        });
    });

    var listHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        searchAll: function () {
            window.location.href = pageUri;
        },
        exportExcel: function () {
            $('#exportDiv').attr("src", exportUri + "?pageIndex=" + pageIndex + "&school=" + $("#school").val() + "&className=" + $("#className").val() + "&reporterName=" + $("#reporterName").val() + "&reporterNum=" + $("#reporterNum").val());
            hot.tip.msg("正在导出中，导出数据量过大可能导致页面反应延迟，请不要刷新页面，耐心等待", 5000);
        }
    }
</script>
</body>
</html>
